<template>
    <el-dialog
        title="指定APK版本"
        :visible.sync="showValue"
        append-to-body
        :close-on-click-modal="false"
        width="1100px"
        top="30px"
        :close="clearData"
        :before-close="clearData"
    >
        <div>
            <el-table
                v-loading="loading"
                :header-cell-style="headerCellStyle"
                :data="tableData"
                size="small"
                max-height="350px"
            >
                <el-table-column
                    prop="createTime"
                    label="状态"
                    show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                    prop="packageName"
                    label="标题"
                    show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                    prop="createTime"
                    label="时间"
                    show-overflow-tooltip
                ></el-table-column>
                <el-table-column fixed="right" align="center" label="操作">
                    <template slot-scope="scope">
                        <el-button
                            size="small"
                            type="primary"
                            @click="checkApk(scope.row)"
                            >详情</el-button
                        >
                    </template>
                </el-table-column>
            </el-table>
        </div>
    </el-dialog>
</template>

<script>
export default {
    props: {
        value: Boolean,
        currRow: Object
    },
    data () {
        return {
            zdList: [],
            currentPage: 1,
            pageSize: 10,
            totalNum: 0,
            loading: false,
            tableData: [],
            showValue: false,
            terminalTypeList: [],
            packageFileTypeList: [],
            form: {
                terminalType: '',
                upgradePackageFileType: ''
            }
        }
    },
    watch: {
        value (val) {
            this.showValue = val
        },
        showValue (val) {
            this.$emit('update:value', val)
            if (val) {
                this.getList()
            }
        }
    },
    created () {
    },
    methods: {
        handleCurrentChange (page) {
            // 换页
            this.currentPage = page
            this.getList()
        },
        // 获取列表
        async getList () {
            this.loading = true
            const res = await this.$http.post(this.$store.state.IP + '/upgradeManage/agentCanUseUpgradePackageList', {
                companyCode: this.currRow.companyCode,
                ...this.form
            })
            let response = res.data
            if (response.ret === '0') {
                this.loading = false
                this.tableData = response.res
            } else {
                this.loading = false
            }
        },
        // 清空数据
        clearData () {
            this.$refs['form'].resetFields()
            this.zdList = []
            this.currentPage = 1
            this.showValue = false
            this.tableData = []
        }
    }
}
</script>
<style lang="stylus" rel="stylesheet/stylus" scoped>
.item
    width: 110px

.right
    text-align: right
</style>